Skip to content

Conversation

ncamera
Copy link
Collaborator

@ncamera ncamera commented Sep 15, 2025

This plugin replaces the need for using the CLI in Vite environments.

This will help us to avoid issues when the Mercury dependency is duplicated. Also, this help us to set this mapping inline in the HTML.
This plugin replaces the need for using the CLI in Vite environments.
Also, inline the base/base bundle by default and preload the base/icons bundle by default.
Also, fix default values for mercuryOptions
@ncamera ncamera added feature Feature implementation pull request mercury Changes related to Mercury design system performance Work related to imporving the performance in the Design System target: minor This PR is targeted for the next minor release labels Sep 15, 2025
@ncamera ncamera marked this pull request as draft September 15, 2025 02:51
…li and vite-mercury-plugin packages

Now, @genexus/mercury only contains the core of Mercury, and we have packages for bulding Mercury, using it through out a CLI, and a plugin to work with Vite.

Breaking changes:
 - The default path for the fonts is now "/assets/fonts/" instead of "./assets/fonts/"

 - The default path for the icons is now "/assets/icons/" instead of "./assets/icons/"
Comment on lines +50 to +52
fileDir: fileMetadata.dir
.replace(MERCURY_DIST_RELATIVE_FOLDERS.DIST_BUNDLES_SCSS, "")
.replace("\\", "/")

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This replaces only the first occurrence of "\".

Copilot Autofix

AI about 9 hours ago

The best fix is to change .replace("\\", "/") to use a global replacement, changing all backslashes in the path, not just the first one. This can be done by switching the argument to replace to a regular expression: .replace(/\\/g, "/"). This approach is concise, robust, and doesn't require any additional method definitions or third-party imports since the RegExp is supported natively. Only a single line change is necessary, at line 52 in packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts.

Suggested changeset 1
packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts b/packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts
--- a/packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts
+++ b/packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts
@@ -49,7 +49,7 @@
   BUNDLES.push({
     fileDir: fileMetadata.dir
       .replace(MERCURY_DIST_RELATIVE_FOLDERS.DIST_BUNDLES_SCSS, "")
-      .replace("\\", "/")
+      .replace(/\\/g, "/")
   });
 
   const transpiledBundle = transpileBundle(filePath, true);
EOF
@@ -49,7 +49,7 @@
BUNDLES.push({
fileDir: fileMetadata.dir
.replace(MERCURY_DIST_RELATIVE_FOLDERS.DIST_BUNDLES_SCSS, "")
.replace("\\", "/")
.replace(/\\/g, "/")
});

const transpiledBundle = transpileBundle(filePath, true);
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +119 to +121
fileDir: fileMetadata.dir
.replace(MERCURY_SRC_RELATIVE_FOLDERS.SRC_BUNDLES_SCSS, "")
.replace("\\", "/")

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This replaces only the first occurrence of "\".

Copilot Autofix

AI about 9 hours ago

To safely replace all backslashes in the directory string with forward slashes, change .replace("\\", "/") to .replace(/\\/g, "/"). This uses a regular expression with the global (g) flag to ensure all backslashes are replaced, regardless of how many are present. The modification should be made directly on line 121 in packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts. No new imports or external libraries are required—the built-in String.replace with regex is sufficient and correct.


Suggested changeset 1
packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts b/packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts
--- a/packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts
+++ b/packages/mercury-build/src/build/internal/transpile-bundle-and-create-mappings.ts
@@ -118,7 +118,7 @@
   BUNDLES.push({
     fileDir: fileMetadata.dir
       .replace(MERCURY_SRC_RELATIVE_FOLDERS.SRC_BUNDLES_SCSS, "")
-      .replace("\\", "/")
+      .replace(/\\/g, "/")
   });
 
   const transpiledBundle = transpileBundle(actualFilePath, hasGlobantVariant);
EOF
@@ -118,7 +118,7 @@
BUNDLES.push({
fileDir: fileMetadata.dir
.replace(MERCURY_SRC_RELATIVE_FOLDERS.SRC_BUNDLES_SCSS, "")
.replace("\\", "/")
.replace(/\\/g, "/")
});

const transpiledBundle = transpileBundle(actualFilePath, hasGlobantVariant);
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Feature implementation pull request mercury Changes related to Mercury design system performance Work related to imporving the performance in the Design System target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant